wayland: Use shm_open(SHM_ANON) on FreeBSD
authormyfreeweb <greg@unrelenting.technology>
Tue, 19 Jun 2018 14:49:18 +0000 (14:49 +0000)
committermyfreeweb <greg@unrelenting.technology>
Tue, 19 Jun 2018 14:49:18 +0000 (14:49 +0000)
This functionality is similar to Linux's memfd. It creates anonymous shared memory without touching the filesystem, which allows it to work in Capsicum capability mode (sandbox).

gdk/wayland/gdkdisplay-wayland.c

index b4ef4485da876c6abf8071b9e1cd03d649a3476f..1e00f292d8e8be6a835459fbe2a8654201416054 100644 (file)
@@ -1276,6 +1276,9 @@ open_shared_memory (void)
 
       if (force_shm_open)
         {
+#if defined (__FreeBSD__)
+          ret = shm_open (SHM_ANON, O_CREAT | O_EXCL | O_RDWR | O_CLOEXEC, 0600);
+#else
           char name[NAME_MAX - 1] = "";
 
           sprintf (name, "/gdk-wayland-%x", g_random_int ());
@@ -1286,6 +1289,7 @@ open_shared_memory (void)
             shm_unlink (name);
           else if (errno == EEXIST)
             continue;
+#endif
         }
     }
   while (ret < 0 && errno == EINTR);